import Vue from 'vue'
import VueRouter from 'vue-router'

import About from '@/views/About'
import Home from '@/views/Home'
import Order from '@/views/Order'
import Type from '@/views/Type'
import Details from '@/views/Details'
import Login from '@/views/Login'
import Register from '@/views/Register'
import Location from '@/views/Location'
import Me from '@/views/Me'
import addLoctaion from '@/views/Location/addLocation'
import updateLocation from '@/views/Location/updateLocation'
import Settlement from '@/views/Settlement'
import OrderDetails from '@/views/OrderDetails'

Vue.use(VueRouter)

// 保存初始的push方法
const originPush = VueRouter.prototype.push

// 重写push方法  参数为原先的配置对象,成功和失败的回调
VueRouter.prototype.push = function (location, resolve, reject) {
    if (resolve && reject) {
        originPush.call(this, location, resolve, reject)
    } else {
        originPush.call(this, location, () => { }, () => { })
    }
}

const router = new VueRouter({
    linkActiveClass: "active",
    routes: [
        {
            path: '/',
            redirect: "/home",
        },
        {
            path: "/home",
            component: Home,
            meta: { isFooter: true },

        },
        {
            path: "/about",
            component: About,
            meta: { isFooter: true },

        },
        {
            path: "/type",
            component: Type,
            meta: { isFooter: true },
        },
        {
            path: "/order",
            component: Order,
            meta: { isFooter: true }
        },
        {
            path: "/details",
            component: Details,
            meta: { isFooter: true }
        },
        {
            path: "/login",
            component: Login,
            meta: {}
        },
        {
            path: "/register",
            component: Register,
            meta: {}
        },
        {
            path: '/location',
            component: Location,
            meta: {},
        },
        {
            path: "/me",
            component: Me,
            meta: {}
        },
        {
            path: "/addLocation",
            component: addLoctaion
        },
        {
            path: "/updateLocation",
            component: updateLocation
        },
        {
            path: '/settlement',
            component: Settlement
        },
        {
            path: '/orderDetails',
            component: OrderDetails
        }

    ]
})

export default router
